#服务器在国外不需要设置镜像加速，国内需要加速才行，不然慢死 需要用最简单的安装，容易出错

#安装docker
echo '安装docker'
sudo -i #切换root账户
yum -y install yum-utils
yum-config-manager --add-repo  https://download.docker.com/linux/centos/docker-ce.repo
yum install docker-ce docker-ce-cli containerd.io
systemctl start docker.service   #启动容器服务
systemctl enable docker.service #设置开机启动
systemctl stop docker.service   #关闭容器服务
systemctl start docker.service   #启动容器服务
docker -v
curl -L "https://github.com/docker/compose/releases/download/1.28.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose  # 下载docker-compose, 也可拷贝其他服务器该工具文件上传到指定位置
chmod +x /usr/local/bin/docker-compose 加执行权限
docker-compose --version

#安装docker上的常用软件
echo '安装docker上的常用软件'
#docker 安装 Jenkins
#下载镜像
echo 'docker 安装 Jenkins'
docker pull  jenkinsci/blueocean
#启动
docker run \
  -u root \
--name jenkins \
  -p 8080:8080 \
  -d  \
  -p 50000:50000 \
  -v jenkins-data:/var/jenkins_home \
  -v /var/run/docker.sock:/var/run/docker.sock \
--restart=always \
  jenkinsci/blueocean
sleep 50s #等待jenkins启动
#jenkinx容器内软件常用软件安装
echo 'jenkinx容器内软件常用软件安装'
docker exec -it jenkins /bin/bash
apk add gradle maven npm
gradle -v
mvn -v
npm -v
npm install cnpm -g --registry=https://registry.npm.taobao.org
#退出jenkins
exit

echo 'docker 安装sqlserver'

docker pull mcr.microsoft.com/mssql/server:2017-latest

#来自 <https://www.cnblogs.com/craigtaylor/p/11143497.html>

 docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=Zq19910303?' \
   -p 1433:1433 --name sqlserver \
   -v sqlserver:/var/opt/mssql/data/ \
   --restart=always \
   -d mcr.microsoft.com/mssql/server:2017-latest


#安装sqlserver2019
sudo docker pull mcr.microsoft.com/mssql/server:2019-latest

   sudo docker run -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=Zq19910303?' \
   --name 'sqlserver' -p 1433:1433 \
   -v sqlserver:/var/opt/mssql \
   --restart=always \
   -d mcr.microsoft.com/mssql/server:2019-latest

echo 'docker 安装tomcat'
docker pull tomcat
docker run -d -p 9000:8080 -v /var/lib/docker/volumes/jenkins-data/_data/tomcat/:/usr/local/tomcat/webapps/ --restart=always --name=tomcat tomcat





